package com.stylefeng.guns.rest.modular.wz.dao;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.rest.common.persistence.dao.*;
import com.stylefeng.guns.rest.common.persistence.model.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 用户数据保存类
 */
@Service
public class WzUserDao {

    @Autowired
    private WzUserMapper userMapper;
    @Autowired
    private WzUserFinanceRecordMapper userFinanceRecordMapper;
    @Autowired
    private PfFinanceRecordMapper pfFinanceRecordMapper;

    /**
     * 用户提现
     */
    @Transactional
    public boolean saveWithdrawals(WzUserFinanceRecord userFinanceRecord, WzUser user) {
        int r = userMapper.updateById(user);
        if(r > 0){
            r = userFinanceRecordMapper.insert(userFinanceRecord);
            if(r > 0){
                return true;
            }
        }
        return false;
    }

}
